//给定一个数组，从中找出出现次数最多的值，输出这个值和它出现的位置
function find(arr) {
  let json = {};
  for (let i = 0; i < arr.length; i++) {
    if (!json[arr[i]]) {
      json[arr[i]] = [i];
    } else {
      json[arr[i]].push(i);
    }
  }
  let maxLength = 0;
  let maxValue = "";
  let indexs;
  for (let key in json) {
    if (json[key].length > maxLength) {
      maxLength = json[key].length;
      maxValue = key;
      indexs = json[key];
    }
  }
  return {
    maxValue,
    indexs,
  };
}
// let arr = [5, 3, 5, 5, 2, 5, 3];
let arr = ["aa", "a", "bb", "a", "aa", "a"];
console.log(find(arr));
